home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Channel Z 6
/
Channel Z - The A1200 Disk Magazine - Issue 6 (1994-06)(Channel Z)(AGA)(Disk 1 of 2).adf
/
Blitz
/
Blitz
Wrap
Text File
|
1992-12-21
|
12KB
|
381 lines
B L I T Z B A S I C - T U T O R I A L # 1
INTRODUCTION
Welcome to my first tutorial for Blitz Basic II.
In the coming tutorials I will be dealing with different aspects of a powerful
language called Blitz Basic II, but before I go into that let me first
introduce myself.
My name is Rudy van Etten I live in the south of Holland in a little town
called Steenbergen. I have owned a A500 for about 4 years now and have
recently bought a A1200. (like a lot of you lately)
When I first hooked it up I immediately noticed the speed difference, I had
placed my old A500 next to my A1200 so I could compare the speed, and I was
quite pleased.
Knowing this and also knowing about the new graphic capabilities I was
planning to go back to programming the amiga again. I used to program in Amos
but I never released anything mainly because of a few reasons.
First of all the executable files are to bloody big and you must state in your
program that it was programmed in Amos, well that is like having lame written
on your forehead.
thirdly the speed was not a real plus point, however on A 1200 it is ofcourse
faster.
And last because Amos has been given the lame status, witch is to bad since it
is pretty capable of standing up between the competition.
When I first heard of Blitz Basic, I thought, "hey, more speed more power I
must get that language".
So after weeks of calling stores all over Holland finally one store had the
brains to include Blitz Basic in their software collection. So after a quick
phone call and a day or two of camping out under the mailbox I was the proud
owner of Blitz Basic II, only to discover that the manual isn't the least
beginner friendly. (here's some old news!!)
I started to read,learn and experiment and I got more used with the command
set every day.
That was one month ago and sins then I have produced, a few simple hardDisk
menus for a quick selection of programs, a simple game experiment (a hi-tech
flying dinosaur robot with the ability to land, coooool!, not!!), and a dorky
looking menu for pack disks.
I hope in this tutorial that you will learn something new, and can begin your
career as a famous, PD or Commercial programmer.
THE REAL START
Well how do you get started with Blitz Basic ?, usually you start with the
installing of the software, but I hope you have done this for yourselves, it
isn't so hard to do.
After the installing you would probably start to look at the included PD
Disks, I really liked the Star Trek game and the shoot 'em up game Cafeine
Free, it really shows the power of Blitz Basic.
Oh, before I forget, be sure that you send in the registration card, because
if you do not register then you will not get any future updates.
After looking at the PD disks I started to look at the examples, not really
something you can use, but they are Ok. After seeing and not understanding
how they all really worked I started typing in little programs like NPrint
"Hello" and Let a=10 : NPrint a, but after a few days the programs got bigger
and better. Also what I liked is that the compiled version of your programs
can be smaller than a few hundred bytes, unlike it's bronze aged cousin Amos.
What I really liked is that Blitz is also fully Assembler friendly, this
meaning you can type any of the assembler mnemonics and Blitz will accept
them.
The Assembler section of Blitz will not be of use to many of you but
it will be for the more experienced users amongst us.(I know your out there!)
For myself however it is not of many use. (But I wish it was!)
However when I tried the assembler commands RTS, JSR and JMP I noticed that
they have the same effect as Return, Gosub and Goto.
Nowing the assembler Mnemonics I knew that RTS means return from subroutine
and JSR means jump to subroutine and that JMP means jump to, so I tried em
out in a little program.
Nprint "One"
JSR two ; same as gosub two
JMP three ; same as goto three
two:
NPrint "Two"
RTS ; same as return
three:
NPrint "Three"
MouseWait
end
When I tried it I found out you can replace the gosubs goto's ect. with the
mnemonics without causing problems.
But enough of that, I will go into that another time.
Wel, let me tell you how not to begin to start programming. Do not
immediately start to memorize all the commands and think you know it all, I
tried that with Assembler once and it didn't help a bit, I knew all
mnemonics and knew not how to use them.
The best is to start to make little programs and expand them when you learn
a new command. Or Just the other way around, learn a new command and make a
little program around it.
Also the best is to look and study the examples in the books and on the disks
and see how a single command works and how everything is set up.
If you have build up enough experience, then you can begin to program small
routines, like controlling a shape via joystick or making a small intro ect.
Later on you will get better and you can start to make bigger programs.
U S E R I N P U T T E S T . .
Now I will show you a simple little program with just asks for your name and
will print it.
;
; User input test..
;
WbToScreen 0 ; Use the workbench screen
Print "What is your name : " ; Print the string to the window
a$=Edit$(20) ; Input 20 characters
NPrint "Hey ",a$," drop dead!!" ; Print the result on the screen
For i=1 To 3 ; Start three loops
BeepScreen 0 : VWait 10 ; Beep the screen, wait a moment
Next ; Next loop
VWait 60 : End ; Wait a sec., end of program
Well I hope everybody sees how it all works and if you don't just look at the
explanation of the commands below.
Statement : WbToScreen screen#
WbToScreen Lets the workbench screen become your screen to work
with.
Statement : Print Expression
Used to print text or numbers to the screen. Most Basic programmers
will recognize this one.
Statement : NPint Expression
Same as Print but will move the cursor down one line after printing
the text or the numbers.
Also if you use the comma's then you can print extra variables and
strings like shown in the example.
Statement : Edit$(number_of_characters)
Edit$ string is what Input$ was for Amos, only it's more powerful
You can set the number of characters to be read in, so if there is
more input from the user, it will not be printed on the screen or
placed in the string.
Statement : For Var=Expression1 To Expression2
For is used to start a loop for a number of times, see the example.
Statement : Next [Var[Var..]
Used to end a For/Next loop, after this command is given then the
program will either jump back for another loop or end the loop and
go on with the program.
Statement : VWait [Frames]
VWait on it own is used to wait until a the display is redrawn, this
is about 1/50 of a second.
You can set the number of frames to wait.
Statement : End
End simply tells Blitz to clean up everything and the quit.
S A V E S C R E E N E X A M P L E
Our second Example is more interesting and more powerful, the program saves
the workbench screen as a ILBM file so you can load it into a paint package
like DPAINT. When you run the program it simply asks you for a save name and
that is all, it then saves the Workbench screen to its destination file.
If you do not give a name or just press cancel then the program will just
quit.
Here follows the program :
;
; Save screen - By Rudy van Etten..
;
WBStartup ; For startup from workbench
NoCli ; Don't run from default cli
WbToScreen 0 ; Use the wbscreen as your own
WBenchToFront_ ; Move it in front
MaxLen path$=192 ; Maximum characters in path$ is 192
MaxLen f$=192 ; Same for f$
path$="Ram:" ; path$ is default "ram:"
; ** Request the filename....
naam$=ASLFileRequest$("Save iff name..",path$,f$,"",50,30,100,180)
If naam$ ; If naam$ is filled
SaveScreen 0,naam$ : VWait 20 : End ; Save it, wait , then end
Else ; If no name is given
Beepscreen_ 0 : End ; Beep the screen, then end
End If
After you typed it try it out. If you typed it correctly then it should
compile Ok, else check for typing errors.
If you have runned the program then there should be a ILBM file at your
selected destination. Try to load it into a art package with the screen size
640,256. or 640,200 for American users.
Below is the explanation of some of the used commands.
Statement : NoCli
NoCli is used to run you program without opening a standard cli
window. This command has no effect in the standalone compiled version
of your code.
Statement : WBenchToFront_
WBenchToFront_ will move the workbench to the front of your display.
Statement : MaxLen StringVar=Expression
MaxLen is used to define a block of memory for a string variable to
grow in.
Statement : ASLFileRequest$(Title$,Pathname$,Filename$[,Pattern][,x,y,w,h])
he ASLFileRequest is build in as a standard in Kickstart 3.0, so no
need to use the less capable Blitz requester.
Title$ is the text on the requester.
Pathname$ is which device or directory shall be given as a default.
Filename$ is which file to choose as a default.
Pattern is used to view or hide files.
x is the x coordinate of the upper-left side of the requester.
y is the y coordinate of the upper side of the requester.
w is the width of the requester.
y is the height of the requester.
Statement : SaveScreen Screen#,Filename$
SaveScreen is used to save the selected screen as a ILBM file, to be
later loaded in to a Paint Package.
Screen# is the screen to be saved, and Filename$ is how shall the
file be saved as.
Well this was our second little program and I hope you have learned something
of it.
Now for some usefull hints tips and tricks when using blitz basic.
B L I T Z H I N T S A N D T I P S . . . .
- If you wish to print on a bitmap in blitz mode the you must first use
BitmapOutput Bitmap# or else your program will halt.
- If you wish to read from the keyboard in blitzmode then first activate
key reading with BlitzKeys On.
- Use Cls [colour#] to clear you screen in Blitz or Amiga mode.
- Use cursor to change the size of your cursor (Cursor 1 = underlined
cursor, Cursor 0 = Default (full cursor)).
- Use Activate in Amiga mode to activate a window (Activate Window#).
- Use BlitzRepeat to change the key speed in Blitz Mode (BlitzRepeat Delay,
Speed)
- Use RawStatus to determine if a key is pressed -1 is given if the key is
pressed (RawStatus (32)).
- Use `Call` to jump to a adress (Call $40000)
- Use IncBin to include a Binary file in your program.
- Use AbsMouse to locate you MousePointer somewhere on the screen (only
available in Amiga mode).
- Use RelMouse to move your MousePointer (Amiga Mode only)
- Use MouseButton to simulate a mousebutton pressing (MouseButton 0,On).
- Use ClickButton to simulate a single mousebutton click. (ClickButton 0)
- Use Type String$ to simulate a typewriter typer.
- On AGA machines use AGARGB palette#,R,G,B to change the palette.
(AGARGB 1,255,10,255).
- How to open a hires screen in AGA, Screen 0,0,0,1280,256,8,$8020,"My
Screen",1,0.
- Use Poke.w $Dff180,a to change the background colour. (a=2)
If you have any comments, questions, tips, example programs, or anything else
that can be of interest to us or the readers then why not let me know.
You can contact me at the address below
Nicolaas Peckstraat 40
4651 DH Steenbergen NB
Holland.